package gepetto.module;

import java.util.TreeMap;

import gepetto.message.Message;

public class AbstractModule implements Module {
	private static TreeMap<String,Module> rooms;
	
	static {
		rooms = new TreeMap<String, Module> ();		
	}
	
	private String name;
	private TreeMap<String,Module> users;
	private TreeMap<String, CallBack<Message>> callbacks;

	protected AbstractModule (String name) {
		this.name = name;
		this.callbacks = new TreeMap<String, CallBack<Message>> ();
	}
	
	public String getName() {
		return name;
	}

	public void process(Message msg) {
		if ((msg.getModule().equals(this.getName())) && (msg.getModule().startsWith(this.getName() + "."))) {
			CallBack<Message> callback = callbacks.get(msg.getId());
			if (callback != null) {
				callback.handle(msg);
			}
		}
	}
	
	public static void deliver (Message msg) {
		
	}
}
